﻿define(function(require,exports,module) {
    var myDate = new Date();
    var maxYear = 120;
    var sEndYear = myDate.getFullYear();
    var sEndMonth = myDate.getMonth();
    var sEndDate = myDate.getDate();
    var sBeginYear = sEndYear - maxYear;

    function SeletBirthday(obj, fn) {
        (function($$) {
            $$.init();
            var result = $$('#result')[0];
            /*var optionsJson  = '{"type":"date","beginYear": '+ sBeginYear +',"endYear":'+ sEndYear +'}';
            var options = JSON.parse(optionsJson);*/
            var picker = new $$.DtPicker({
                // 真正的月份比写的多一个月。  type的类型你还是可以选择date, datetime month time  hour
                type: "date",                                                       // 设置日历初始视图模式
                beginDate: new Date(sBeginYear, 00, 01) ,                                              // 设置开始日期   
                endDate: new Date(sEndYear, sEndMonth, sEndDate)                    // 设置结束日期   
            });
            obj[0].addEventListener('click', function() {
                picker.show(function(rs) {
                    obj.find('.js_inputBirthday').text(rs.text);
                    /*
                     * 返回 false 可以阻止选择框的关闭
                     * return false;
                     */

                    if(fn)fn(rs.text)
                    // saveBirthday(rs.text);
                });
            }, false);

        })(mui);
    }

    exports.SeletBirthday = SeletBirthday;

});



